#include "kutils.h"

#include <cstring>

bool my_strequ(const char* s1, const char* s2)
{
	for (register int i = 0; s1[i] || s2[i]; ++i)
		if (s1[i] != s2[i])
			return false;

	return true;
}

void my_strcpy(char **dest, const char *src)
{
	int len = strlen(src) + 1;
	*dest = new char[len];
#ifdef _MSC_VER
	strcpy_s(*dest, len, src);
#else
	strncpy(*dest, src, len);
#endif
}

k_uint hash(const char *str)
{
	unsigned int h = 0;
	const char *s;

	for (s = str; *s; ++s)
		h = ((h << 4) | (h >> 28)) ^ *s; // _rotl(h, 4) ^ *s

	return (k_uint)h;
}
